package pkg.genericity.utils;

import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;

import pkg.genericity.annot.Parser;

public class FieldInfo {

	public FieldInfo(Field field) {
		super();
		this.field = field;
	}

	private Field field;

	public Field getField() {
		return field;
	}

	public void setField(Field field) {
		this.field = field;
	}
	
	public String getName() {
		return field.getName();
	}
	
	public String getType() {
		return field.getType().getSimpleName();
	}
	
	public boolean isRequired() {
		return new Parser().isRequired(this.field);
	}
	
	public String getTypeInfo() {
		String required= isRequired() ?"required":"";
		List<String> numericTypes = Arrays.asList( new String[] {"Integer","Double","Float","Byte","int","byte","double","float"} );
		String type = numericTypes.contains(getType()) ? "number":"string";
		
		return (required+" "+type).trim();
	}
}
